import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class Hello {
    private static Map<String, String> properties = new HashMap<String, String>();

    static {
        initProperties();
    }

    public static void main(String[] args) {
        System.out.println("Gitee Hello.");

        for (String key : properties.keySet()) {
            System.out.println(key + " : " + properties.get(key));
        }
    }

    public String getProperties(String key){
        return properties.get(key);
    }

    public static void initProperties() {
        Properties prop = new Properties();
        InputStream inpup = new Hello().getClass().getClassLoader().getResourceAsStream("my.properties");
        try {
            prop.load(new InputStreamReader(inpup, StandardCharsets.UTF_8));
            Enumeration<Object> e = prop.keys();
            while (e.hasMoreElements()) {
                String key = e.nextElement().toString();
                properties.put(key, prop.getProperty(key));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
